package com.ltu.websocket.respone;

import com.alibaba.fastjson.JSON;
import com.ltu.model.response.base.CodeDataResp;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class WebSocketRespEncoder implements Encoder.Text<CodeDataResp> {

    @Override
    public String encode(CodeDataResp resp) throws EncodeException {
        try {
            return JSON.toJSONString(resp, false);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public void init(EndpointConfig endpointConfig) {
    	
    }

    @Override
    public void destroy() {

    }

}
